using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using JBORPG.Net;
using JBORPG.Server.Handlers;

namespace JBORPG.Server
{
    public partial class frmMain : Form
    {
        private NetHandler m_NetHandler;
        private Net.Server m_Server;
        private System.Timers.Timer m_Timer;

        public frmMain()
        {
            InitializeComponent();

            m_Timer = new System.Timers.Timer();
            m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
        }

        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            m_NetHandler.InvokeOnAll("Tick");
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            m_NetHandler = new NetHandler();

            m_Server = new JBORPG.Net.Server(m_NetHandler, Properties.Settings.Default.Port);
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            m_Server.Listen();
            this.Text = "Servern lyssnar";
        }
    }
}